package SetTest;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * MapTest
 *
 * @author byc
 * @date 2022-04-22
 */
public class MapTest {

    public static void main(String[] args) {
        Map<Integer,String> map = new HashMap<>();
         map.put(1,"xx");
         map.put(2,"yy");
         map.put(3,"ww");
         map.put(4,"bb");
         map.put(5,"00");

        Set<Map.Entry<Integer,String>> set = map.entrySet();
        //迭代器方法
        Iterator<Map.Entry<Integer,String>> it = set.iterator();
        while (it.hasNext()){
            Map.Entry<Integer,String> node = it.next();
            Integer key = node.getKey();
            String value = node.getValue();
            System.out.println(key + " : " + value);
        }
    }

}
